package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.StandardBonusWorkingYears;
import com.group.project.hrms.mapper.StandardBonusWorkingYearsMapper;
import com.group.project.hrms.service.IStandardBonusWorkingYearsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class StandardBonusWorkingYearsService implements IStandardBonusWorkingYearsService {

    @Autowired
    private StandardBonusWorkingYearsMapper standardBonusWorkingYearsMapper;


    @Override
    public int insertStandardBonusWorkingYears(StandardBonusWorkingYears standardBonusWorkingYears) {
        return standardBonusWorkingYearsMapper.insert(standardBonusWorkingYears);
    }

    @Override
    public int deleteStandardBonusWorkingYears(StandardBonusWorkingYears standardBonusWorkingYears) {
        return standardBonusWorkingYearsMapper.deleteByPrimaryKey(standardBonusWorkingYears);
    }

    @Override
    public int updateStandardBonusWorkingYears(StandardBonusWorkingYears standardBonusWorkingYears) {
        return standardBonusWorkingYearsMapper.updateByPrimaryKey(standardBonusWorkingYears);
    }

    @Override
    public StandardBonusWorkingYears selectOneStandardBonusWorkingYears(StandardBonusWorkingYears standardBonusWorkingYears) {
        return null;
    }

    @Override
    public StandardBonusWorkingYears selectOneStandardBonusWorkingYearsByGIDAndYear(String gid, Integer year) {
        Example example = new Example(StandardBonusWorkingYears.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("attendGroupId" , gid);
        criteria.andEqualTo("workingYears", year);
        return standardBonusWorkingYearsMapper.selectOneByExample(example);
    }

    @Override
    public List<StandardBonusWorkingYears> selectAllStandardBonusWorkingYears() {
        return standardBonusWorkingYearsMapper.selectAll();
    }
}
